$(function () {

    $("body").css("opacity","1")

    $("#shengqing").click(function(){
        console.log(1);
        $(this).css({"background-color":"#007dd2","color":"white"})
        $("#chaxun").css({"background-color":"white","color":"black"})
        $("#shengqing1").show(500)
        $("#chaxun1").hide(500)
    });

    $("#chaxun").click(function(){
        console.log(1);
        $(this).css({"background-color":"#007dd2","color":"white"})
        $("#shengqing").css({"background-color":"white","color":"black"})
        $("#chaxun1").show(500)
        $("#shengqing1").hide(500)
    });


    var username = localStorage.getItem("username");
    $.post("/xjxt/xuejizhuangtai?username="+ username +"",function(res){

        var hehe = JSON.parse(res);
        console.log(hehe);
        $("#knumber").html(hehe[0].knumber);
        $("#xnumber").html(hehe[0].xnumber);
        $("#name").html(hehe[0].name);
        $("#sex").html(hehe[0].sex);
        $("#birthday").html(hehe[0].birthday);
        $("#ID").html(hehe[0].ID);
        $("#nation").html(hehe[0].nation);
        $("#school").html(hehe[0].school);
        $("#nschool").html(hehe[0].nschool);
        $("#inday").html(hehe[0].inday);
        $("#zhuangtai").html(hehe[0].zhuangtai);
        $("#username").val(hehe[0].username);
        $("#touxiang").attr("src",hehe[0].touxiang);

    });


    $.post("/xjxt/xuejichaxun?username="+ username +"",function(res){

        var hehe = JSON.parse(res);
        console.log(hehe);

        //动态的创建一个table，同时将后台获取的数据动态的填充到相应的单元格
        $("#xjchaxun").append("<tr>"+ "<td>" + "姓名" +"</td>" + "<td>" + "申请类型"+"</td>" +"<td>" + "状态" +"</td>"+ "<td>" + "意见" +"</td>"+"</tr>");
        $.each(hehe, function (colIndex, col) {

            if (col.gaibian == "01")
            {col.gaibian = "在读"}

            if (col.gaibian == "02")
            {col.gaibian = "休学"}

            if (col.gaibian == "03")
            {col.gaibian = "当兵"}

            if (col.gaibian == "04")
            {col.gaibian = "病休"}

            if (col.gaibian == "05")
            {col.gaibian = "延期"}

            if (col.queren == "0")
            {col.queren = "尚未处理"}

            if (col.queren == "1")
            {col.queren = "同意改变"}

            if (col.queren == "2")
            {col.queren = "不同意改变"}
                var th;
                th+="<td>" + col.name+"</td>" + "<td>" +col.gaibian+"</td>" + "<td>" +col.queren+"</td>" + "<td>" +col.yijian+"</td>";
                $("#xjchaxun").append("<tr>" + th + "</tr>");


        });
    });


});